////
////#ifndef MANIPULATE2_H
////#define MANIPULATE2_H
////
////#define BOX_FRICTION 0.85f
////#define GROUND_FRICTION 0.75f
////#define FINGER_FRICTION 1.5f
////#define BOX_DENSITY 1300.0f;
////#define FINGER_DENSITY 1069.0f;
////#define BOX_SIZE 0.5f
////#define FINGER_SIZE 0.05f
////#define MOUSE_JOINT_FREQUENCY 15.0f
////#define MOUSE_JOINT_DAMPING_RATIO 1.0f
////#define SPACE 0.001f
////#define FORCE_SCALE 0.00001f
////#define POSITION_SCALE 0.5f
////#define GROUND_POSITION b2Vec2(0.0f, 0.0f)
////
////#include <vector>
////
////class Manipulate2 : public Test
////{
////public:
////	enum
////	{
////		e_boxDensityBit	= 0x0001,
////		e_boxSizeBit = 0x0002,
////		e_boxFrictionBit = 0x0004,
////		e_fingerFrictionBit = 0x0008,
////		e_groundFrictionBit = 0x0010,
////		e_frequencyBit = 0x0020,
////		e_dampingRatioBit = 0x0040,
////		e_groundShiftingBit = 0x0080
////	};
////
////	enum
////	{
////		e_writeForce	= 0x0001,
////		e_writePosition = 0x0002
////	};
////
////	Manipulate2()
////	{		
////		m_boxBody = NULL;
////		m_fingerBody = NULL;
////		m_groundBody = NULL;
////		m_fingerFixture = NULL;
////		m_isTouched = false;
////		m_trajectoryInput = NULL;
////		m_trajectoryOutput = NULL;
////		m_fingerPosition.SetZero();
////		m_pullPointPosition.SetZero();
////		m_linearVelocity.SetZero();
////		m_linearVelocityOld.SetZero();
////		m_replayIterations = -1;
////		m_boxFriction = BOX_FRICTION;
////		m_groundFriction = GROUND_FRICTION;
////		m_fingerFriction = FINGER_FRICTION;
////		m_boxDensity = BOX_DENSITY;
////		m_boxSize = BOX_SIZE;
////		m_fingerDensity = FINGER_DENSITY;
////		m_fingerSize = FINGER_SIZE;
////		m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
////		m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
////		m_groundPosition = GROUND_POSITION;
////
////		DrawBox(b2Vec2(-1.5f + m_boxSize, m_groundPosition.y + m_boxSize));
////		DrawGround(m_groundPosition);
////	}
////
////	void DrawGround(b2Vec2 groundPosition)
////	{
////		b2BodyDef myBodyDef;
////		myBodyDef.type = b2_staticBody;
////		myBodyDef.position = groundPosition;
////
////		b2EdgeShape groundShape;
////		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(1.5f, 0.0f));
////		b2FixtureDef myFixtureDef;
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0f;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody = m_world->CreateBody(&myBodyDef);
////		m_groundBody->CreateFixture(&myFixtureDef);
////
////		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(-1.5f, 1.2f));
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody->CreateFixture(&myFixtureDef);
////
////		groundShape.Set(b2Vec2(1.5f, 0.0f), b2Vec2(1.5f, 1.2f));
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody->CreateFixture(&myFixtureDef);
////	}
////
////	void DrawBox(b2Vec2 boxPosition)
////	{
////		b2BodyDef myBodyDef;
////		myBodyDef.type = b2_dynamicBody;
////		myBodyDef.position = boxPosition;
////		myBodyDef.userData = &m_isTouched;
////
////		//shape definition
////		b2PolygonShape polygonShape;
////		polygonShape.SetAsBox(m_boxSize, m_boxSize);
////
////		//fixture definition
////		b2FixtureDef myFixtureDef;
////		myFixtureDef.shape = &polygonShape;
////		myFixtureDef.density = m_boxDensity;
////		myFixtureDef.friction = m_boxFriction;
////
////		m_boxBody = m_world->CreateBody(&myBodyDef);
////		m_boxBody->CreateFixture(&myFixtureDef);
////	}
////
////	static Test* Create()
////	{
////		return new Manipulate2;
////	}
////
////	void MouseDown(const b2Vec2& p)
////	{
////		m_fingerPosition = p;
////
////		{
////			b2BodyDef myBodyDef;
////			myBodyDef.type = b2_dynamicBody;
////			myBodyDef.position = m_boxBody->GetWorldPoint(m_fingerPosition);
////
////			b2PolygonShape fingerShape;
////			fingerShape.SetAsBox(0.05f, 0.05f);
////
////			b2FixtureDef myFixtureDef;
////			myFixtureDef.shape = &fingerShape;
////			myFixtureDef.density = m_fingerDensity;
////			myFixtureDef.friction = m_fingerFriction;
////
////			m_fingerBody = m_world->CreateBody(&myBodyDef);
////			m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////			if(!m_isTouched)
////			{
////				b2Vec2 invGravityForce = m_world->GetGravity();
////				invGravityForce *= -1.0f * m_fingerBody->GetMass();
////				m_fingerBody -> ApplyForceToCenter(invGravityForce);
////			}
////		}
////	}
////
////	void MouseMove(const b2Vec2& p)
////	{
////		if(m_isTouched)
////		{
////			m_pullPointPosition = p;
////		}
////		else
////		{
////			m_fingerPosition = p;
////			m_pullPointPosition = p;
////		}
////	}
////
////	void MouseUp(const b2Vec2& p)
////	{
////		m_isTouched = false;
////
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////
////		if(m_mouseJoint)
////		{
////			m_world->DestroyJoint(m_mouseJoint);
////			m_mouseJoint = NULL;
////		}
////	}
////
////	void DrawFinger()
////	{
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////		else
////		{
////			return;
////		}
////
////		{
////			b2BodyDef myBodyDef;
////			myBodyDef.type = b2_dynamicBody;
////			myBodyDef.position = m_fingerPosition;
////
////			b2PolygonShape fingerShape;
////			fingerShape.SetAsBox(0.05f, 0.05f);
////
////			b2FixtureDef myFixtureDef;
////			myFixtureDef.shape = &fingerShape;
////			myFixtureDef.density = m_fingerDensity;
////			myFixtureDef.friction = m_fingerFriction;
////
////			m_fingerBody = m_world->CreateBody(&myBodyDef);
////			m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////		}
////	}
////
////	void ForceOnBox(const b2Vec2& p, Settings* settings)
////	{
////		//m_fingerPosition = m_fingerBody->GetPosition();
////		//
////		//b2Vec2 forceArrow = m_mouseJoint->GetReactionForce(settings->hz);
////		//b2Vec2 fingerPointPosition = m_fingerBody->GetPosition();
////		//
////		//{
////		//	forceArrow.Normalize();
////		//	forceArrow *= -1;
////		//	forceArrow += fingerPointPosition;
////		//	m_debugDraw.DrawSegment(fingerPointPosition, forceArrow, b2Color(0.9f, 0.9f, 0.9f));
////
////		//	b2Transform xf;
////		//	float32 angle = b2Atan2(forceArrow.y - fingerPointPosition.y, forceArrow.x - fingerPointPosition.x);
////		//	xf.q.Set(angle);
////		//	xf.p = fingerPointPosition;
////
////		//	b2Vec2 vertices[3];
////		//	vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
////		//	vertices[1] = b2Mul(xf, b2Vec2(0.15f, -0.05f));
////		//	vertices[2] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
////		//	m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
////
////
////		//	vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
////		//	vertices[1] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
////		//	vertices[2] = b2Mul(xf, b2Vec2(0.15f, 0.05f));
////		//	m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
////		//}
////	}
////
////	void BeginContact(b2Contact* contact)
////	{
////		b2Fixture* fixtureA = contact->GetFixtureA();
////		b2Fixture* fixtureB = contact->GetFixtureB();
////
////		if (fixtureA == m_fingerFixture)
////		{
////			void* userData = fixtureB->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = true;
////			}
////		}
////
////		if (fixtureB == m_fingerFixture)
////		{
////			void* userData = fixtureA->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = true;
////			}
////		}
////	}
////
////	//// Implement contact listener.
////	void EndContact(b2Contact* contact)
////	{
////		b2Fixture* fixtureA = contact->GetFixtureA();
////		b2Fixture* fixtureB = contact->GetFixtureB();
////
////		if (fixtureA == m_fingerFixture)
////		{
////			void* userData = fixtureB->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = false;
////			}
////		}
////
////		if (fixtureB == m_fingerFixture)
////		{
////			void* userData = fixtureA->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = false;
////			}
////		}
////	}
////
////	void Step(Settings* settings)
////	{
////		if(m_fingerBody)
////		{
////			b2Vec2 invGravityForce = m_world->GetGravity();
////			invGravityForce *= -1.0f * m_fingerBody->GetMass();
////			m_fingerBody->ApplyForceToCenter(invGravityForce);
////		}
////
////		uint32 flags = 0;
////		flags += settings->enableBoxDensityNoise * e_boxDensityBit;
////		flags += settings->enableBoxSizeNoise * e_boxSizeBit;
////		flags += settings->enableBoxFrictionNoise * e_boxFrictionBit;
////		flags += settings->enableFingerFrictionNoise * e_fingerFrictionBit;
////		flags += settings->enableGroundFrictionNoise * e_groundFrictionBit;
////		flags += settings->enableMouseJointFrequencyNoise * e_frequencyBit;
////		flags += settings->enableMouseJointDampingRatioNoise * e_dampingRatioBit;
////		flags += settings->enableGroundShiftingNoise * e_groundShiftingBit;
////		m_noiseFlag = flags;
////
////		if(!settings->isRecord && settings->isReplay && m_replayIterations != 0)
////		{
////			if(Replaying(settings) != EOF)
////			{
////				if(!strcmp(m_flag, "1"))
////				{
////					if(!m_isTouched)
////					{
////						if(m_fingerBody)
////						{
////							m_world->DestroyBody(m_fingerBody);
////							m_fingerBody = NULL;
////						}
////
////						b2BodyDef myBodyDef;
////						myBodyDef.type = b2_dynamicBody;
////						myBodyDef.position = m_fingerPosition;
////
////						b2PolygonShape fingerShape;
////						fingerShape.SetAsBox(0.05f, 0.05f);
////
////						b2FixtureDef myFixtureDef;
////						myFixtureDef.shape = &fingerShape;
////						myFixtureDef.density = m_fingerDensity;
////						myFixtureDef.friction = m_fingerFriction;
////
////						m_fingerBody = m_world->CreateBody(&myBodyDef);
////						m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////
////						b2MouseJointDef md;
////						md.bodyA = m_groundBody;
////						md.bodyB = m_fingerBody;
////						md.target = m_fingerBody->GetPosition();
////						md.maxForce = 10000.0f * m_fingerBody->GetMass();
////						md.dampingRatio = m_mouseJointDampingRatio;
////						md.frequencyHz = m_mouseJointFrequency;
////						m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
////						m_fingerBody->SetAwake(true);
////					}
////					else
////					{
////						m_mouseWorld = m_pullPointPosition;
////						m_mouseJoint->SetTarget(m_pullPointPosition);
////						ForceOnBox(m_pullPointPosition, settings);
////					}
////				}
////				else if(!strcmp(m_flag, "2"))
////				{
////					if(m_mouseJoint)
////					{
////						m_world->DestroyJoint(m_mouseJoint);
////						m_mouseJoint = NULL;
////					}
////					if(m_fingerBody)
////					{
////						m_world->DestroyBody(m_fingerBody);
////						m_fingerBody = NULL;
////					}
////				}
////			}
////			else
////			{
////				m_replayIterations--;			
////				StopReplay(settings);
////			}
////		}
////		else
////		{
////			if(m_isTouched)
////			{
////				if(!m_mouseJoint)
////				{
////					b2MouseJointDef md;
////					md.bodyA = m_groundBody;
////					md.bodyB = m_fingerBody;
////					md.target = m_fingerBody->GetPosition();
////					md.maxForce = 10000.0f * m_fingerBody->GetMass();
////					md.dampingRatio = m_mouseJointDampingRatio;
////					md.frequencyHz = m_mouseJointFrequency;
////					m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
////					m_fingerBody->SetAwake(true);
////				}
////				else
////				{
////					m_mouseWorld = m_pullPointPosition;
////					m_mouseJoint->SetTarget(m_pullPointPosition);
////				}
////				ForceOnBox(m_pullPointPosition, settings);
////			}
////			else
////			{
////				DrawFinger();
////			}
////			if(settings->isRecord)
////			{
////				Recording(settings);
////			}
////		}
////
////		if(m_fingerBody)
////		{
////			b2Vec2 externalForce;
////			externalForce.SetZero();
////			if(m_mouseJoint)
////				externalForce = m_mouseJoint->GetReactionForce(settings->hz);
////			b2Vec2 invGravityForce = m_world->GetGravity();
////			invGravityForce *= -1.0f * m_fingerBody->GetMass();
////			externalForce += invGravityForce;
////			m_externalForceCollection.push_back(externalForce);
////			m_fingerPositionCollection.push_back(m_fingerPosition);
////		}
////
////		DrawInfo();
////		Test::Step(settings);
////	}
////
////	void DrawInfo()
////	{
////		{
////			char infoValue[15];
////			char title[50] = "BoxSize: ";
////			sprintf(infoValue, "%.6f", m_boxSize);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[30] = "BoxDensity: ";
////			sprintf(infoValue, "%.6f", m_boxDensity);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "BoxFriction: ";
////			sprintf(infoValue, "%.6f", m_boxFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "FingerFriction: ";
////			sprintf(infoValue, "%.6f", m_fingerFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "GroundFriction: ";
////			sprintf(infoValue, "%.6f", m_groundFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "MouseJointFrequency: ";
////			sprintf(infoValue, "%.6f", m_mouseJointFrequency);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "MouseJointDampingRatio: ";
////			sprintf(infoValue, "%.6f", m_mouseJointDampingRatio);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[20];
////			char title[50] = "GroundBodyPosition: ";
////			sprintf(infoValue, "%.6f %.6f", m_groundPosition.x, m_groundPosition.y);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////	}
////
////	string CurrentDateTime() 
////	{
////		time_t now = time(0);
////		struct tm  tstruct;
////		char buf[80];
////		tstruct = *localtime(&now);
////		strftime(buf, sizeof(buf), "%Y-%m-%d-%H-%M-%S", &tstruct);
////		return buf;
////	}
////
////	void Recording(Settings* settings)
////	{
////		if(m_fileName.empty())
////		{
////			m_fileName = CurrentDateTime();
////			settings->fileName = m_fileName;
////		}
////		if(!m_trajectoryOutput)
////		{
////			char path[100] = ".\\trajectory\\";
////			strcat(path, m_fileName.c_str());
////			m_trajectoryOutput = fopen(path, "at+");
////		}
////
////		if(m_fingerBody)
////		{
////			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "1", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);	
////		}
////		else
////		{
////			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "2", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);
////		}
////	}
////
////	void StopRecord()
////	{
////		if(m_trajectoryOutput)
////		{
////			fclose(m_trajectoryOutput);
////			m_trajectoryOutput = NULL;
////		}
////		m_fileName = "";
////	}
////
////	int Replaying(Settings* settings)
////	{
////		if(m_fileName.empty())
////		{	
////			m_fileName = settings->fileName;
////		}
////		if(!m_trajectoryInput)
////		{
////			char path[100] = ".\\trajectory\\";
////			strcat(path, m_fileName.c_str());
////			m_trajectoryInput = fopen(path, "r");
////			if(m_replayIterations == -1)
////			{
////				m_replayIterations = settings->replayIterations;
////				m_externalForceCollection.clear();
////				m_fingerPositionCollection.clear();
////			}
////			if(m_noiseFlag & e_boxDensityBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxDensity += 350.0f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_boxSizeBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxSize += 0.01f;
////				boxPosition.x += 0.01f;
////				boxPosition.y += 0.01f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_boxFrictionBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxFriction += 0.1f;
////				//if(m_boxFriction > 1.0f)
////				//	m_boxFriction = 1.0f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_fingerFrictionBit)
////			{
////				m_fingerFriction += 0.05f;
////				if(m_fingerFriction > 1.0f)
////					m_fingerFriction = 1.0f;
////				DrawFinger();
////			}
////			if(m_noiseFlag & e_groundFrictionBit)
////			{
////				m_groundFriction += 0.05f;
////				if(m_groundFriction > 1.0f)
////					m_groundFriction = 1.0f;
////
////				if(m_groundBody)
////				{
////					m_world->DestroyBody(m_groundBody);
////					m_groundBody = NULL;
////				}
////				DrawGround(m_groundPosition);
////			}
////			if(m_noiseFlag & e_frequencyBit)
////			{
////				m_mouseJointFrequency += 0.5f;
////				if(m_mouseJoint)
////				{
////					m_world->DestroyJoint(m_mouseJoint);
////					m_mouseJoint = NULL;
////				}
////			}
////			if(m_noiseFlag & e_dampingRatioBit)
////			{
////				m_mouseJointDampingRatio += 0.05f;
////				if(m_mouseJoint)
////				{
////					m_world->DestroyJoint(m_mouseJoint);
////					m_mouseJoint = NULL;
////				}
////			}
////			if(m_noiseFlag & e_groundShiftingBit)
////			{
////				m_groundPosition.y += 0.1f;
////				
////				if(m_groundBody)
////				{
////					m_world->DestroyBody(m_groundBody);
////					m_groundBody = NULL;
////				}
////				DrawGround(m_groundPosition);
////
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				boxPosition.y += 0.1f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////		}
////		return fscanf(m_trajectoryInput, "%s %f %f %f %f\n", &m_flag, &m_fingerPosition.x, &m_fingerPosition.y, &m_pullPointPosition.x, &m_pullPointPosition.y);
////	}
////
////	void StopReplay(Settings* settings)
////	{
////		if(m_replayIterations == 0)
////		{
////			settings->isReplay = !settings->isReplay;
////
////			m_boxFriction = BOX_FRICTION;
////			m_groundFriction = GROUND_FRICTION;
////			m_fingerFriction = FINGER_FRICTION;
////			m_boxDensity = BOX_DENSITY;
////			m_boxSize = BOX_SIZE;
////			m_fingerDensity = FINGER_DENSITY;
////			m_fingerSize = FINGER_SIZE;
////			m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
////			m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
////
////			FILE* dataFileName = fopen(".\\data_file_name", "w");
////			fprintf(dataFileName, "%s\n", m_fileName.c_str());
////			fclose(dataFileName);
////
////			uint32 flags = 0;
////			flags += settings->enableForceDataWrite * e_writeForce;
////			flags += settings->enablePositionDataWrite * e_writePosition;
////
////			if(flags & e_writeForce)
////			{	
////				char path[100] = ".\\figure_data\\force\\";
////				strcat(path, m_fileName.c_str());
////				FILE* forceDataOutput = fopen(path, "w");
////				vector<b2Vec2>::iterator iter;
////				for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++) 
////					fprintf(forceDataOutput, "%f %f\n", (*iter).x, (*iter).y);
////				fclose(forceDataOutput);
////			}
////
////			if(flags & e_writePosition)
////			{
////				char path[100] = ".\\figure_data\\position\\";
////				strcat(path, m_fileName.c_str());
////				FILE* positionDataOutput = fopen(path, "w");
////				vector<b2Vec2>::iterator iter;
////				for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++) 
////					fprintf(positionDataOutput, "%f %f\n", (*iter).x, (*iter).y);
////				fclose(positionDataOutput);
////			}
////
////			m_replayIterations = -1;
////		}
////
////		if(m_trajectoryInput)
////		{		
////			fclose(m_trajectoryInput);
////			m_trajectoryInput = NULL;
////		}
////
////		m_isTouched = false;
////
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////
////		if(m_mouseJoint)
////		{
////			m_world->DestroyJoint(m_mouseJoint);
////			m_mouseJoint = NULL;
////		}
////	}
////
////	void DrawForceX()
////	{
////		m_debugDraw.DrawString(45, 10, "Force X (N) (SCALE 1/10000)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_externalForceCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawForceY()
////	{
////		m_debugDraw.DrawString(45, 10, "Force Y (N) (SCALE 1/10000)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_externalForceCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawPositionX()
////	{
////		m_debugDraw.DrawString(45, 10, "Position X (M) (SCALE 1/2)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_fingerPositionCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawPositionY()
////	{
////		m_debugDraw.DrawString(45, 10, "Position Y (M) (SCALE 1/2)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_fingerPositionCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	b2Body* m_boxBody;
////	b2Body* m_fingerBody;
////	b2Body* m_groundBody;
////	b2Fixture* m_fingerFixture;
////	bool m_isTouched;
////	b2Vec2 m_fingerPosition;
////	b2Vec2 m_pullPointPosition;
////	FILE* m_trajectoryInput;
////	FILE* m_trajectoryOutput;
////	string m_fileName;
////	char m_flag[6];
////	uint32 m_noiseFlag;
////	int32 m_replayIterations;
////	b2Vec2 m_linearVelocity;
////	b2Vec2 m_linearVelocityOld;
////	std::vector<b2Vec2> m_externalForceCollection;
////	std::vector<b2Vec2> m_fingerPositionCollection;
////	float32 m_boxFriction;
////	float32 m_groundFriction;
////	float32 m_fingerFriction;
////	float32 m_boxDensity;
////	float32 m_boxSize;
////	float32 m_fingerSize;
////	float32 m_fingerDensity;
////	float32 m_mouseJointFrequency;
////	float32 m_mouseJointDampingRatio;
////	b2Vec2 m_groundPosition;
////};
////
////#endif
////
////
////#ifndef MANIPULATE2_H
////#define MANIPULATE2_H
////
////#define BOX_FRICTION 0.85f
////#define GROUND_FRICTION 0.75f
////#define FINGER_FRICTION 1.5f
////#define BOX_DENSITY 1300.0f;
////#define FINGER_DENSITY 1069.0f;
////#define BOX_SIZE 0.5f
////#define FINGER_SIZE 0.05f
////#define MOUSE_JOINT_FREQUENCY 15.0f
////#define MOUSE_JOINT_DAMPING_RATIO 1.0f
////#define SPACE 0.001f
////#define FORCE_SCALE 0.00001f
////#define POSITION_SCALE 0.5f
////#define GROUND_POSITION b2Vec2(0.0f, 0.0f)
////
////#include <vector>
////
////class Manipulate2 : public Test
////{
////public:
////	enum
////	{
////		e_boxDensityBit	= 0x0001,
////		e_boxSizeBit = 0x0002,
////		e_boxFrictionBit = 0x0004,
////		e_fingerFrictionBit = 0x0008,
////		e_groundFrictionBit = 0x0010,
////		e_frequencyBit = 0x0020,
////		e_dampingRatioBit = 0x0040,
////		e_groundShiftingBit = 0x0080
////	};
////
////	enum
////	{
////		e_writeForce	= 0x0001,
////		e_writePosition = 0x0002
////	};
////
////	Manipulate2()
////	{		
////		m_boxBody = NULL;
////		m_fingerBody = NULL;
////		m_groundBody = NULL;
////		m_fingerFixture = NULL;
////		m_isTouched = false;
////		m_trajectoryInput = NULL;
////		m_trajectoryOutput = NULL;
////		m_fingerPosition.SetZero();
////		m_pullPointPosition.SetZero();
////		m_linearVelocity.SetZero();
////		m_linearVelocityOld.SetZero();
////		m_replayIterations = -1;
////		m_boxFriction = BOX_FRICTION;
////		m_groundFriction = GROUND_FRICTION;
////		m_fingerFriction = FINGER_FRICTION;
////		m_boxDensity = BOX_DENSITY;
////		m_boxSize = BOX_SIZE;
////		m_fingerDensity = FINGER_DENSITY;
////		m_fingerSize = FINGER_SIZE;
////		m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
////		m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
////		m_groundPosition = GROUND_POSITION;
////
////		DrawBox(b2Vec2(-1.5f + m_boxSize, m_groundPosition.y + m_boxSize));
////		DrawGround(m_groundPosition);
////	}
////
////	void DrawGround(b2Vec2 groundPosition)
////	{
////		b2BodyDef myBodyDef;
////		myBodyDef.type = b2_staticBody;
////		myBodyDef.position = groundPosition;
////
////		b2EdgeShape groundShape;
////		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(1.5f, 0.0f));
////		b2FixtureDef myFixtureDef;
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0f;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody = m_world->CreateBody(&myBodyDef);
////		m_groundBody->CreateFixture(&myFixtureDef);
////
////		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(-1.5f, 1.2f));
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody->CreateFixture(&myFixtureDef);
////
////		groundShape.Set(b2Vec2(1.5f, 0.0f), b2Vec2(1.5f, 1.2f));
////		myFixtureDef.shape = &groundShape;
////		myFixtureDef.density = 0.0;
////		myFixtureDef.friction = m_groundFriction;
////		m_groundBody->CreateFixture(&myFixtureDef);
////	}
////
////	void DrawBox(b2Vec2 boxPosition)
////	{
////		b2BodyDef myBodyDef;
////		myBodyDef.type = b2_dynamicBody;
////		myBodyDef.position = boxPosition;
////		myBodyDef.userData = &m_isTouched;
////
////		//shape definition
////		b2PolygonShape polygonShape;
////		polygonShape.SetAsBox(m_boxSize, m_boxSize);
////
////		//fixture definition
////		b2FixtureDef myFixtureDef;
////		myFixtureDef.shape = &polygonShape;
////		myFixtureDef.density = m_boxDensity;
////		myFixtureDef.friction = m_boxFriction;
////
////		m_boxBody = m_world->CreateBody(&myBodyDef);
////		m_boxBody->CreateFixture(&myFixtureDef);
////	}
////
////	static Test* Create()
////	{
////		return new Manipulate2;
////	}
////
////	void MouseDown(const b2Vec2& p)
////	{
////		m_fingerPosition = p;
////
////		{
////			b2BodyDef myBodyDef;
////			myBodyDef.type = b2_dynamicBody;
////			myBodyDef.position = m_boxBody->GetWorldPoint(m_fingerPosition);
////
////			b2PolygonShape fingerShape;
////			fingerShape.SetAsBox(0.05f, 0.05f);
////
////			b2FixtureDef myFixtureDef;
////			myFixtureDef.shape = &fingerShape;
////			myFixtureDef.density = m_fingerDensity;
////			myFixtureDef.friction = m_fingerFriction;
////
////			m_fingerBody = m_world->CreateBody(&myBodyDef);
////			m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////			if(!m_isTouched)
////			{
////				b2Vec2 invGravityForce = m_world->GetGravity();
////				invGravityForce *= -1.0f * m_fingerBody->GetMass();
////				m_fingerBody -> ApplyForceToCenter(invGravityForce);
////			}
////		}
////	}
////
////	void MouseMove(const b2Vec2& p)
////	{
////		if(m_isTouched)
////		{
////			m_pullPointPosition = p;
////		}
////		else
////		{
////			m_fingerPosition = p;
////			m_pullPointPosition = p;
////		}
////	}
////
////	void MouseUp(const b2Vec2& p)
////	{
////		m_isTouched = false;
////
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////
////		if(m_mouseJoint)
////		{
////			m_world->DestroyJoint(m_mouseJoint);
////			m_mouseJoint = NULL;
////		}
////	}
////
////	void DrawFinger()
////	{
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////		else
////		{
////			return;
////		}
////
////		{
////			b2BodyDef myBodyDef;
////			myBodyDef.type = b2_dynamicBody;
////			myBodyDef.position = m_fingerPosition;
////
////			b2PolygonShape fingerShape;
////			fingerShape.SetAsBox(0.05f, 0.05f);
////
////			b2FixtureDef myFixtureDef;
////			myFixtureDef.shape = &fingerShape;
////			myFixtureDef.density = m_fingerDensity;
////			myFixtureDef.friction = m_fingerFriction;
////
////			m_fingerBody = m_world->CreateBody(&myBodyDef);
////			m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////		}
////	}
////
////	void ForceOnBox(const b2Vec2& p, Settings* settings)
////	{
////		//m_fingerPosition = m_fingerBody->GetPosition();
////		//
////		//b2Vec2 forceArrow = m_mouseJoint->GetReactionForce(settings->hz);
////		//b2Vec2 fingerPointPosition = m_fingerBody->GetPosition();
////		//
////		//{
////		//	forceArrow.Normalize();
////		//	forceArrow *= -1;
////		//	forceArrow += fingerPointPosition;
////		//	m_debugDraw.DrawSegment(fingerPointPosition, forceArrow, b2Color(0.9f, 0.9f, 0.9f));
////
////		//	b2Transform xf;
////		//	float32 angle = b2Atan2(forceArrow.y - fingerPointPosition.y, forceArrow.x - fingerPointPosition.x);
////		//	xf.q.Set(angle);
////		//	xf.p = fingerPointPosition;
////
////		//	b2Vec2 vertices[3];
////		//	vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
////		//	vertices[1] = b2Mul(xf, b2Vec2(0.15f, -0.05f));
////		//	vertices[2] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
////		//	m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
////
////
////		//	vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
////		//	vertices[1] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
////		//	vertices[2] = b2Mul(xf, b2Vec2(0.15f, 0.05f));
////		//	m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
////		//}
////	}
////
////	void BeginContact(b2Contact* contact)
////	{
////		b2Fixture* fixtureA = contact->GetFixtureA();
////		b2Fixture* fixtureB = contact->GetFixtureB();
////
////		if (fixtureA == m_fingerFixture)
////		{
////			void* userData = fixtureB->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = true;
////			}
////		}
////
////		if (fixtureB == m_fingerFixture)
////		{
////			void* userData = fixtureA->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = true;
////			}
////		}
////	}
////
////	//// Implement contact listener.
////	void EndContact(b2Contact* contact)
////	{
////		b2Fixture* fixtureA = contact->GetFixtureA();
////		b2Fixture* fixtureB = contact->GetFixtureB();
////
////		if (fixtureA == m_fingerFixture)
////		{
////			void* userData = fixtureB->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = false;
////			}
////		}
////
////		if (fixtureB == m_fingerFixture)
////		{
////			void* userData = fixtureA->GetBody()->GetUserData();
////			if (userData)
////			{
////				bool* touching = (bool*)userData;
////				*touching = false;
////			}
////		}
////	}
////
////	void Step(Settings* settings)
////	{
////		if(m_fingerBody)
////		{
////			b2Vec2 invGravityForce = m_world->GetGravity();
////			invGravityForce *= -1.0f * m_fingerBody->GetMass();
////			m_fingerBody->ApplyForceToCenter(invGravityForce);
////		}
////
////		uint32 flags = 0;
////		flags += settings->enableBoxDensityNoise * e_boxDensityBit;
////		flags += settings->enableBoxSizeNoise * e_boxSizeBit;
////		flags += settings->enableBoxFrictionNoise * e_boxFrictionBit;
////		flags += settings->enableFingerFrictionNoise * e_fingerFrictionBit;
////		flags += settings->enableGroundFrictionNoise * e_groundFrictionBit;
////		flags += settings->enableMouseJointFrequencyNoise * e_frequencyBit;
////		flags += settings->enableMouseJointDampingRatioNoise * e_dampingRatioBit;
////		flags += settings->enableGroundShiftingNoise * e_groundShiftingBit;
////		m_noiseFlag = flags;
////
////		if(!settings->isRecord && settings->isReplay && m_replayIterations != 0)
////		{
////			if(Replaying(settings) != EOF)
////			{
////				if(!strcmp(m_flag, "1"))
////				{
////					if(!m_isTouched)
////					{
////						if(m_fingerBody)
////						{
////							m_world->DestroyBody(m_fingerBody);
////							m_fingerBody = NULL;
////						}
////
////						b2BodyDef myBodyDef;
////						myBodyDef.type = b2_dynamicBody;
////						myBodyDef.position = m_fingerPosition;
////
////						b2PolygonShape fingerShape;
////						fingerShape.SetAsBox(0.05f, 0.05f);
////
////						b2FixtureDef myFixtureDef;
////						myFixtureDef.shape = &fingerShape;
////						myFixtureDef.density = m_fingerDensity;
////						myFixtureDef.friction = m_fingerFriction;
////
////						m_fingerBody = m_world->CreateBody(&myBodyDef);
////						m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
////
////						b2MouseJointDef md;
////						md.bodyA = m_groundBody;
////						md.bodyB = m_fingerBody;
////						md.target = m_fingerBody->GetPosition();
////						md.maxForce = 10000.0f * m_fingerBody->GetMass();
////						md.dampingRatio = m_mouseJointDampingRatio;
////						md.frequencyHz = m_mouseJointFrequency;
////						m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
////						m_fingerBody->SetAwake(true);
////					}
////					else
////					{
////						m_mouseWorld = m_pullPointPosition;
////						m_mouseJoint->SetTarget(m_pullPointPosition);
////						ForceOnBox(m_pullPointPosition, settings);
////					}
////				}
////				else if(!strcmp(m_flag, "2"))
////				{
////					if(m_mouseJoint)
////					{
////						m_world->DestroyJoint(m_mouseJoint);
////						m_mouseJoint = NULL;
////					}
////					if(m_fingerBody)
////					{
////						m_world->DestroyBody(m_fingerBody);
////						m_fingerBody = NULL;
////					}
////				}
////			}
////			else
////			{
////				m_replayIterations--;			
////				StopReplay(settings);
////			}
////		}
////		else
////		{
////			if(m_isTouched)
////			{
////				if(!m_mouseJoint)
////				{
////					b2MouseJointDef md;
////					md.bodyA = m_groundBody;
////					md.bodyB = m_fingerBody;
////					md.target = m_fingerBody->GetPosition();
////					md.maxForce = 10000.0f * m_fingerBody->GetMass();
////					md.dampingRatio = m_mouseJointDampingRatio;
////					md.frequencyHz = m_mouseJointFrequency;
////					m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
////					m_fingerBody->SetAwake(true);
////				}
////				else
////				{
////					m_mouseWorld = m_pullPointPosition;
////					m_mouseJoint->SetTarget(m_pullPointPosition);
////				}
////				ForceOnBox(m_pullPointPosition, settings);
////			}
////			else
////			{
////				DrawFinger();
////			}
////			if(settings->isRecord)
////			{
////				Recording(settings);
////			}
////		}
////
////		if(m_fingerBody)
////		{
////			b2Vec2 externalForce;
////			externalForce.SetZero();
////			if(m_mouseJoint)
////				externalForce = m_mouseJoint->GetReactionForce(settings->hz);
////			b2Vec2 invGravityForce = m_world->GetGravity();
////			invGravityForce *= -1.0f * m_fingerBody->GetMass();
////			externalForce += invGravityForce;
////			m_externalForceCollection.push_back(externalForce);
////			m_fingerPositionCollection.push_back(m_fingerPosition);
////		}
////
////		DrawInfo();
////		Test::Step(settings);
////	}
////
////	void DrawInfo()
////	{
////		{
////			char infoValue[15];
////			char title[50] = "BoxSize: ";
////			sprintf(infoValue, "%.6f", m_boxSize);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[30] = "BoxDensity: ";
////			sprintf(infoValue, "%.6f", m_boxDensity);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "BoxFriction: ";
////			sprintf(infoValue, "%.6f", m_boxFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "FingerFriction: ";
////			sprintf(infoValue, "%.6f", m_fingerFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "GroundFriction: ";
////			sprintf(infoValue, "%.6f", m_groundFriction);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "MouseJointFrequency: ";
////			sprintf(infoValue, "%.6f", m_mouseJointFrequency);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[15];
////			char title[50] = "MouseJointDampingRatio: ";
////			sprintf(infoValue, "%.6f", m_mouseJointDampingRatio);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////
////		{
////			char infoValue[20];
////			char title[50] = "GroundBodyPosition: ";
////			sprintf(infoValue, "%.6f %.6f", m_groundPosition.x, m_groundPosition.y);
////			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
////			m_textLine += 15;
////		}
////	}
////
////	string CurrentDateTime() 
////	{
////		time_t now = time(0);
////		struct tm  tstruct;
////		char buf[80];
////		tstruct = *localtime(&now);
////		strftime(buf, sizeof(buf), "%Y-%m-%d-%H-%M-%S", &tstruct);
////		return buf;
////	}
////
////	void Recording(Settings* settings)
////	{
////		if(m_fileName.empty())
////		{
////			m_fileName = CurrentDateTime();
////			settings->fileName = m_fileName;
////		}
////		if(!m_trajectoryOutput)
////		{
////			char path[100] = ".\\trajectory\\";
////			strcat(path, m_fileName.c_str());
////			m_trajectoryOutput = fopen(path, "at+");
////		}
////
////		if(m_fingerBody)
////		{
////			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "1", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);	
////		}
////		else
////		{
////			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "2", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);
////		}
////	}
////
////	void StopRecord()
////	{
////		if(m_trajectoryOutput)
////		{
////			fclose(m_trajectoryOutput);
////			m_trajectoryOutput = NULL;
////		}
////		m_fileName = "";
////	}
////
////	int Replaying(Settings* settings)
////	{
////		if(m_fileName.empty())
////		{	
////			m_fileName = settings->fileName;
////		}
////		if(!m_trajectoryInput)
////		{
////			char path[100] = ".\\trajectory\\";
////			strcat(path, m_fileName.c_str());
////			m_trajectoryInput = fopen(path, "r");
////			if(m_replayIterations == -1)
////			{
////				m_replayIterations = settings->replayIterations;
////				m_externalForceCollection.clear();
////				m_fingerPositionCollection.clear();
////			}
////			if(m_noiseFlag & e_boxDensityBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxDensity += 350.0f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_boxSizeBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxSize += 0.01f;
////				boxPosition.x += 0.01f;
////				boxPosition.y += 0.01f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_boxFrictionBit)
////			{
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				m_boxFriction += 0.1f;
////				//if(m_boxFriction > 1.0f)
////				//	m_boxFriction = 1.0f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////			if(m_noiseFlag & e_fingerFrictionBit)
////			{
////				m_fingerFriction += 0.05f;
////				if(m_fingerFriction > 1.0f)
////					m_fingerFriction = 1.0f;
////				DrawFinger();
////			}
////			if(m_noiseFlag & e_groundFrictionBit)
////			{
////				m_groundFriction += 0.05f;
////				if(m_groundFriction > 1.0f)
////					m_groundFriction = 1.0f;
////
////				if(m_groundBody)
////				{
////					m_world->DestroyBody(m_groundBody);
////					m_groundBody = NULL;
////				}
////				DrawGround(m_groundPosition);
////			}
////			if(m_noiseFlag & e_frequencyBit)
////			{
////				m_mouseJointFrequency += 0.5f;
////				if(m_mouseJoint)
////				{
////					m_world->DestroyJoint(m_mouseJoint);
////					m_mouseJoint = NULL;
////				}
////			}
////			if(m_noiseFlag & e_dampingRatioBit)
////			{
////				m_mouseJointDampingRatio += 0.05f;
////				if(m_mouseJoint)
////				{
////					m_world->DestroyJoint(m_mouseJoint);
////					m_mouseJoint = NULL;
////				}
////			}
////			if(m_noiseFlag & e_groundShiftingBit)
////			{
////				m_groundPosition.y += 0.1f;
////				
////				if(m_groundBody)
////				{
////					m_world->DestroyBody(m_groundBody);
////					m_groundBody = NULL;
////				}
////				DrawGround(m_groundPosition);
////
////				b2Vec2 boxPosition = m_boxBody->GetPosition();
////				boxPosition.y += 0.1f;
////				if(m_boxBody)
////				{
////					m_world->DestroyBody(m_boxBody);
////					m_boxBody = NULL;
////				}
////				DrawBox(boxPosition);
////			}
////		}
////		return fscanf(m_trajectoryInput, "%s %f %f %f %f\n", &m_flag, &m_fingerPosition.x, &m_fingerPosition.y, &m_pullPointPosition.x, &m_pullPointPosition.y);
////	}
////
////	void StopReplay(Settings* settings)
////	{
////		if(m_replayIterations == 0)
////		{
////			settings->isReplay = !settings->isReplay;
////
////			m_boxFriction = BOX_FRICTION;
////			m_groundFriction = GROUND_FRICTION;
////			m_fingerFriction = FINGER_FRICTION;
////			m_boxDensity = BOX_DENSITY;
////			m_boxSize = BOX_SIZE;
////			m_fingerDensity = FINGER_DENSITY;
////			m_fingerSize = FINGER_SIZE;
////			m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
////			m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
////
////			FILE* dataFileName = fopen(".\\data_file_name", "w");
////			fprintf(dataFileName, "%s\n", m_fileName.c_str());
////			fclose(dataFileName);
////
////			uint32 flags = 0;
////			flags += settings->enableForceDataWrite * e_writeForce;
////			flags += settings->enablePositionDataWrite * e_writePosition;
////
////			if(flags & e_writeForce)
////			{	
////				char path[100] = ".\\figure_data\\force\\";
////				strcat(path, m_fileName.c_str());
////				FILE* forceDataOutput = fopen(path, "w");
////				vector<b2Vec2>::iterator iter;
////				for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++) 
////					fprintf(forceDataOutput, "%f %f\n", (*iter).x, (*iter).y);
////				fclose(forceDataOutput);
////			}
////
////			if(flags & e_writePosition)
////			{
////				char path[100] = ".\\figure_data\\position\\";
////				strcat(path, m_fileName.c_str());
////				FILE* positionDataOutput = fopen(path, "w");
////				vector<b2Vec2>::iterator iter;
////				for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++) 
////					fprintf(positionDataOutput, "%f %f\n", (*iter).x, (*iter).y);
////				fclose(positionDataOutput);
////			}
////
////			m_replayIterations = -1;
////		}
////
////		if(m_trajectoryInput)
////		{		
////			fclose(m_trajectoryInput);
////			m_trajectoryInput = NULL;
////		}
////
////		m_isTouched = false;
////
////		if(m_fingerBody)
////		{
////			m_world->DestroyBody(m_fingerBody);
////			m_fingerBody = NULL;
////		}
////
////		if(m_mouseJoint)
////		{
////			m_world->DestroyJoint(m_mouseJoint);
////			m_mouseJoint = NULL;
////		}
////	}
////
////	void DrawForceX()
////	{
////		m_debugDraw.DrawString(45, 10, "Force X (N) (SCALE 1/10000)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_externalForceCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawForceY()
////	{
////		m_debugDraw.DrawString(45, 10, "Force Y (N) (SCALE 1/10000)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_externalForceCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawPositionX()
////	{
////		m_debugDraw.DrawString(45, 10, "Position X (M) (SCALE 1/2)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_fingerPositionCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	void DrawPositionY()
////	{
////		m_debugDraw.DrawString(45, 10, "Position Y (M) (SCALE 1/2)");
////		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
////		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
////
////		int i = 0;
////		vector<b2Vec2>::iterator iter;
////		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
////		{ 
////			if(iter + 1 != m_fingerPositionCollection.end())
////			{
////				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
////			}
////		}
////	}
////
////	b2Body* m_boxBody;
////	b2Body* m_fingerBody;
////	b2Body* m_groundBody;
////	b2Fixture* m_fingerFixture;
////	bool m_isTouched;
////	b2Vec2 m_fingerPosition;
////	b2Vec2 m_pullPointPosition;
////	FILE* m_trajectoryInput;
////	FILE* m_trajectoryOutput;
////	string m_fileName;
////	char m_flag[6];
////	uint32 m_noiseFlag;
////	int32 m_replayIterations;
////	b2Vec2 m_linearVelocity;
////	b2Vec2 m_linearVelocityOld;
////	std::vector<b2Vec2> m_externalForceCollection;
////	std::vector<b2Vec2> m_fingerPositionCollection;
////	float32 m_boxFriction;
////	float32 m_groundFriction;
////	float32 m_fingerFriction;
////	float32 m_boxDensity;
////	float32 m_boxSize;
////	float32 m_fingerSize;
////	float32 m_fingerDensity;
////	float32 m_mouseJointFrequency;
////	float32 m_mouseJointDampingRatio;
////	b2Vec2 m_groundPosition;
////};
////
////#endif
//
//
//#ifndef MANIPULATE2_H
//#define MANIPULATE2_H
//
//#define BOX_FRICTION 0.85f
//#define GROUND_FRICTION 0.75f
//#define FINGER_FRICTION 1.5f
//#define BOX_DENSITY 1300.0f;
//#define FINGER_DENSITY 1069.0f;
//#define BOX_SIZE 0.5f
//#define FINGER_SIZE 0.05f
//#define MOUSE_JOINT_FREQUENCY 15.0f
//#define MOUSE_JOINT_DAMPING_RATIO 1.0f
//#define SPACE 0.001f
//#define FORCE_SCALE 0.00001f
//#define POSITION_SCALE 0.5f
//#define GROUND_POSITION b2Vec2(0.0f, 0.0f)
//#define FINGER_POSITION b2Vec2(-1.000000, 1.850000)
//
//#include <vector>
//#include <algorithm>
//#include <functional>   
//#include <cstdlib>
//
//class Manipulate2 : public Test
//{
//public:
//	enum
//	{
//		e_boxDensityBit	= 0x0001,
//		e_boxSizeBit = 0x0002,
//		e_boxFrictionBit = 0x0004,
//		e_fingerFrictionBit = 0x0008,
//		e_groundFrictionBit = 0x0010,
//		e_frequencyBit = 0x0020,
//		e_dampingRatioBit = 0x0040,
//		e_groundShiftingBit = 0x0080
//	};
//
//	enum
//	{
//		e_writeForce	= 0x0001,
//		e_writePosition = 0x0002
//	};
//
//	class QueryCallback : public b2QueryCallback
//	{
//	public:
//		QueryCallback(const b2Vec2& point)
//		{
//			m_point = point;
//			m_fixture = NULL;
//		}
//
//		bool ReportFixture(b2Fixture* fixture)
//		{
//			b2Body* body = fixture->GetBody();
//			if (body->GetType() == b2_dynamicBody)
//			{
//				bool inside = fixture->TestPoint(m_point);
//				if (inside)
//				{
//					m_fixture = fixture;
//
//					return false;
//				}
//			}
//
//			return true;
//		}
//
//		b2Vec2 m_point;
//		b2Fixture* m_fixture;
//	};
//
//	class RecordInfo
//	{
//	public:
//		b2Vec2 fingerPosition;
//		b2Vec2 pullPointPosition;
//		string flag;
//		int timeStep;
//	public:
//		RecordInfo(b2Vec2 fingerPosition, b2Vec2 pullPointPosition, string flag, int timeStep)
//		{
//			this->fingerPosition = fingerPosition;
//			this->pullPointPosition = pullPointPosition;
//			this->flag = flag;
//			this->timeStep = timeStep;
//		}
//		b2Vec2 GetFingerPosition()
//		{
//			return this->fingerPosition;
//		}
//
//		b2Vec2 GetPullPointPosition()
//		{
//			return this->pullPointPosition;
//		}
//
//		string GetFlag()
//		{
//			return this->flag;
//		}
//
//		int GetTimeStep()
//		{
//			return this->timeStep;
//		}
//	};
//
//	class RecordInfo_flag_equ : public unary_function<RecordInfo, bool>
//	{
//	public:
//		string flag;
//		explicit RecordInfo_flag_equ(const string s):flag(s){};
//		bool operator ()(const RecordInfo& ri){return !ri.flag.compare(flag);}
//	};
//
//	Manipulate2()
//	{		
//		m_boxBody = NULL;
//		m_fingerBody = NULL;
//		m_groundBody = NULL;
//		m_fingerFixture = NULL;
//		m_isTouched = false;
//		m_trajectoryInput = NULL;
//		m_trajectoryOutput = NULL;
//		m_dataFile = NULL;
//		m_linearVelocity.SetZero();
//		m_linearVelocityOld.SetZero();
//		m_replayIterations = -1;
//		m_recordInfo.clear();
//		m_boxFriction = BOX_FRICTION;
//		m_groundFriction = GROUND_FRICTION;
//		m_fingerFriction = FINGER_FRICTION;
//		m_boxDensity = BOX_DENSITY;
//		m_boxSize = BOX_SIZE;
//		m_fingerDensity = FINGER_DENSITY;
//		m_fingerSize = FINGER_SIZE;
//		m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
//		m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
//		m_groundPosition = GROUND_POSITION;
//		m_fingerPosition = FINGER_POSITION;
//		m_shiftingAdaptionEnd = false;
//		m_shiftingAdaptionStart = false;
//
//		DrawBox(b2Vec2(-1.5f + m_boxSize, m_groundPosition.y + m_boxSize));
//		DrawGround(m_groundPosition);
//		DrawFinger();
//	}
//
//	void DrawFinger()
//	{
//		{
//			b2BodyDef myBodyDef;
//			myBodyDef.type = b2_dynamicBody;
//			myBodyDef.position = m_fingerPosition;
//
//			b2CircleShape fingerShape;
//			fingerShape.m_radius = 0.05f;
//			//b2PolygonShape fingerShape;
//			//fingerShape.SetAsBox(0.05f, 0.05f);
//
//			b2FixtureDef myFixtureDef;
//			myFixtureDef.shape = &fingerShape;
//			myFixtureDef.density = m_fingerDensity;
//			myFixtureDef.friction = m_fingerFriction;
//
//			m_fingerBody = m_world->CreateBody(&myBodyDef);
//			m_fingerFixture = m_fingerBody->CreateFixture(&myFixtureDef);
//			m_fingerBody->SetFixedRotation(true);
//
//		}
//	}
//
//	void DrawGround(b2Vec2 groundPosition)
//	{
//		b2BodyDef myBodyDef;
//		myBodyDef.type = b2_staticBody;
//		myBodyDef.position = groundPosition;
//
//		b2EdgeShape groundShape;
//		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(1.5f, 0.0f));
//		b2FixtureDef myFixtureDef;
//		myFixtureDef.shape = &groundShape;
//		myFixtureDef.density = 0.0f;
//		myFixtureDef.friction = m_groundFriction;
//		m_groundBody = m_world->CreateBody(&myBodyDef);
//		m_groundBody->CreateFixture(&myFixtureDef);
//
//		groundShape.Set(b2Vec2(-1.5f, 0.0f), b2Vec2(-1.5f, 1.2f));
//		myFixtureDef.shape = &groundShape;
//		myFixtureDef.density = 0.0;
//		myFixtureDef.friction = m_groundFriction;
//		m_groundBody->CreateFixture(&myFixtureDef);
//
//		groundShape.Set(b2Vec2(1.5f, 0.0f), b2Vec2(1.5f, 1.2f));
//		myFixtureDef.shape = &groundShape;
//		myFixtureDef.density = 0.0;
//		myFixtureDef.friction = m_groundFriction;
//		m_groundBody->CreateFixture(&myFixtureDef);
//	}
//
//	void DrawBox(b2Vec2 boxPosition)
//	{
//		b2BodyDef myBodyDef;
//		myBodyDef.type = b2_dynamicBody;
//		myBodyDef.position = boxPosition;
//		myBodyDef.userData = &m_isTouched;
//
//		//shape definition
//		b2PolygonShape polygonShape;
//		polygonShape.SetAsBox(m_boxSize, m_boxSize);
//
//		//fixture definition
//		b2FixtureDef myFixtureDef;
//		myFixtureDef.shape = &polygonShape;
//		myFixtureDef.density = m_boxDensity;
//		myFixtureDef.friction = m_boxFriction;
//
//		m_boxBody = m_world->CreateBody(&myBodyDef);
//		m_boxBody->CreateFixture(&myFixtureDef);
//	}
//
//	static Test* Create()
//	{
//		return new Manipulate2;
//	}
//
//	void MouseDown(const b2Vec2& p)
//	{
//		if(!m_mouseJoint)
//		{
//			b2AABB aabb;
//			b2Vec2 d;
//			d.Set(0.001f, 0.001f);
//			aabb.lowerBound = p - d;
//			aabb.upperBound = p + d;
//
//			QueryCallback callback(p);
//			m_world->QueryAABB(&callback, aabb);
//
//			if (callback.m_fixture)
//			{
//				b2Body* body = callback.m_fixture->GetBody();
//				if(body == m_fingerBody)
//				{
//					b2MouseJointDef md;
//					md.bodyA = m_groundBody;
//					md.bodyB = m_fingerBody;
//					md.target = m_fingerBody -> GetPosition();
//					md.maxForce = 10000.0f * body->GetMass();
//					md.dampingRatio = m_mouseJointDampingRatio;
//					md.frequencyHz = m_mouseJointFrequency;
//					m_fingerPosition = m_fingerBody -> GetPosition();
//					m_pullPointPosition = m_fingerBody -> GetPosition();
//					m_mouseWorld = m_fingerBody -> GetPosition();
//					m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
//					m_fingerBody->SetAwake(true);
//				}
//			}
//		}
//	}
//
//	void MouseMove(const b2Vec2& p)
//	{
//		if (m_mouseJoint)
//			m_mouseJoint->SetTarget(p);
//		m_pullPointPosition = p;
//	}
//
//	void MouseUp(const b2Vec2& p)
//	{
//		if(m_mouseJoint)
//		{
//			m_world->DestroyJoint(m_mouseJoint);
//			m_mouseJoint = NULL;
//		}
//
//		//if(m_fingerBody)
//		//{
//		//	m_fingerPosition = m_fingerBody->GetPosition();
//		//	m_pullPointPosition = m_fingerBody->GetPosition();
//		//	m_world->DestroyBody(m_fingerBody);
//		//	m_fingerBody = NULL;
//		//	DrawFinger();
//		//}
//	}
//
//	void ForceOnBox(Settings* settings)
//	{
//		m_fingerPosition = m_fingerBody->GetPosition();
//
//		b2Vec2 forceArrow = m_mouseJoint->GetReactionForce(settings->hz);
//		b2Vec2 fingerPointPosition = m_fingerBody->GetPosition();
//
//		{
//			forceArrow.Normalize();
//			forceArrow *= -1;
//			forceArrow += fingerPointPosition;
//			m_debugDraw.DrawSegment(fingerPointPosition, forceArrow, b2Color(0.9f, 0.9f, 0.9f));
//
//			b2Transform xf;
//			float32 angle = b2Atan2(forceArrow.y - fingerPointPosition.y, forceArrow.x - fingerPointPosition.x);
//			xf.q.Set(angle);
//			xf.p = fingerPointPosition;
//
//			b2Vec2 vertices[3];
//			vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
//			vertices[1] = b2Mul(xf, b2Vec2(0.15f, -0.05f));
//			vertices[2] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
//			m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
//
//
//			vertices[0] = b2Mul(xf, b2Vec2(0.0f, 0.0f));
//			vertices[1] = b2Mul(xf, b2Vec2(0.1f, 0.0f));
//			vertices[2] = b2Mul(xf, b2Vec2(0.15f, 0.05f));
//			m_debugDraw.DrawPolygon(vertices, 3, b2Color(0.9f, 0.9f, 0.9f));
//		}
//	}
//
//	void BeginContact(b2Contact* contact)
//	{
//		b2Fixture* fixtureA = contact->GetFixtureA();
//		b2Fixture* fixtureB = contact->GetFixtureB();
//
//		if (fixtureA == m_fingerFixture)
//		{
//			void* userData = fixtureB->GetBody()->GetUserData();
//			if (userData)
//			{
//				bool* touching = (bool*)userData;
//				*touching = true;
//			}
//		}
//
//		if (fixtureB == m_fingerFixture)
//		{
//			void* userData = fixtureA->GetBody()->GetUserData();
//			if (userData)
//			{
//				bool* touching = (bool*)userData;
//				*touching = true;
//			}
//		}
//	}
//
//	//// Implement contact listener.
//	void EndContact(b2Contact* contact)
//	{
//		b2Fixture* fixtureA = contact->GetFixtureA();
//		b2Fixture* fixtureB = contact->GetFixtureB();
//
//		if (fixtureA == m_fingerFixture)
//		{
//			void* userData = fixtureB->GetBody()->GetUserData();
//			if (userData)
//			{
//				bool* touching = (bool*)userData;
//				*touching = false;
//			}
//		}
//
//		if (fixtureB == m_fingerFixture)
//		{
//			void* userData = fixtureA->GetBody()->GetUserData();
//			if (userData)
//			{
//				bool* touching = (bool*)userData;
//				*touching = false;
//			}
//		}
//	}
//
//	void Step(Settings* settings)
//	{
//		uint32 flags = 0;
//		flags += settings->enableBoxDensityNoise * e_boxDensityBit;
//		flags += settings->enableBoxSizeNoise * e_boxSizeBit;
//		flags += settings->enableBoxFrictionNoise * e_boxFrictionBit;
//		flags += settings->enableFingerFrictionNoise * e_fingerFrictionBit;
//		flags += settings->enableGroundFrictionNoise * e_groundFrictionBit;
//		flags += settings->enableMouseJointFrequencyNoise * e_frequencyBit;
//		flags += settings->enableMouseJointDampingRatioNoise * e_dampingRatioBit;
//		flags += settings->enableGroundShiftingNoise * e_groundShiftingBit;
//		m_noiseFlag = flags;
//
//		m_fingerPosition = m_fingerBody -> GetPosition();
//		if(m_mouseJoint == NULL)
//			m_pullPointPosition = m_fingerPosition;
//
//		if(!settings->isRecord && settings->isReplay && m_replayIterations != 0)
//		{
//			static int timeStep = 0;
//
//			if(timeStep == 0)
//			{
//				AddNoise(settings);
//				m_isTouched = false;
//				m_shiftingAdaptionEnd = false;
//				m_shiftingAdaptionStart = false;
//				m_externalForceCollection.clear();
//				m_fingerPositionCollection.clear();
//			}
//
//			RecordInfo recordInfo = m_recordInfo.at(timeStep);
//			m_pullPointPosition = recordInfo.GetPullPointPosition();
//			m_flag = recordInfo.GetFlag();
//
//			if(m_isTouched && settings->enableShiftingUpAdaptation && !m_shiftingAdaptionStart && !m_shiftingAdaptionEnd && m_flag.compare("2") && (m_flag.compare("3")))
//			{
//				vector<RecordInfo>::iterator iter_2 = std::find_if(m_recordInfo.begin(), m_recordInfo.end(), RecordInfo_flag_equ("2"));
//				int timeStep_2 = iter_2 == m_recordInfo.end() ? m_recordInfo.size() : iter_2 -> GetTimeStep();
//				vector<RecordInfo>::iterator iter_3 = std::find_if(m_recordInfo.begin(), m_recordInfo.end(), RecordInfo_flag_equ("3"));
//				int timeStep_3 = iter_3 == m_recordInfo.end() ? m_recordInfo.size() : iter_3 -> GetTimeStep();
//
//				int timeStep_min = timeStep_2 < timeStep_3 ? timeStep_2 : timeStep_3;
//
//				if(timeStep_min < m_recordInfo.size())
//				{
//					m_recordedFingerPosition = m_recordInfo.at(timeStep_min).GetFingerPosition();
//					timeStep = timeStep_min;
//					m_adaptiveDiff = m_fingerPosition.y - m_recordedFingerPosition.y;
//				}
//				m_shiftingAdaptionStart = true;
//			}
//
//			if(settings->enableShiftingUpAdaptation && m_shiftingAdaptionStart && !m_shiftingAdaptionEnd)
//			{
//				if(abs(m_fingerPosition.x - m_recordedFingerPosition.x) <= b2_epsilon)
//				{
//					m_adaptiveDiff = m_fingerPosition.y - m_recordedFingerPosition.y;
//					m_shiftingAdaptionEnd = true;
//				}
//				else
//				{
//					m_mouseJoint -> SetTarget(b2Vec2(m_recordedFingerPosition.x, m_fingerPosition.y));
//				}
//			}
//
//			else
//			{
//				if(settings->enableShiftingUpAdaptation && m_shiftingAdaptionStart && m_shiftingAdaptionEnd)
//				{
//					m_pullPointPosition.y += m_adaptiveDiff;
//				}
//
//				if(!m_flag.compare("3") || !m_flag.compare("4"))
//				{
//					if(m_mouseJoint == NULL)
//					{
//						b2MouseJointDef md;
//						md.bodyA = m_groundBody;
//						md.bodyB = m_fingerBody;
//						md.target = m_fingerBody -> GetPosition();
//						md.maxForce = 10000.0f * m_fingerBody->GetMass();
//						md.dampingRatio = m_mouseJointDampingRatio;
//						md.frequencyHz = m_mouseJointFrequency;
//						m_mouseWorld = m_fingerBody -> GetPosition();
//						m_mouseJoint = (b2MouseJoint*)m_world->CreateJoint(&md);
//						m_fingerBody->SetAwake(true);
//					}
//					m_mouseWorld = m_pullPointPosition;
//					m_mouseJoint->SetTarget(m_pullPointPosition);
//					//m_isTouched = (!strcmp(m_flag, "3")) ? true : false;
//				}
//
//				if(!m_flag.compare("1") || !m_flag.compare("2"))
//				{
//					if(m_mouseJoint != NULL)
//					{
//						m_world->DestroyJoint(m_mouseJoint);
//						m_mouseJoint = NULL;
//					}
//					//m_isTouched = (!strcmp(m_flag, "2")) ? true : false;
//				}
//
//				timeStep++;
//			}
//
//			if(m_isTouched && m_mouseJoint)
//			{
//				//ForceOnBox(settings);
//			}
//
//			if(timeStep == m_recordInfo.size())
//			{
//				m_replayIterations--;
//				timeStep = 0;
//				StopReplay(settings);
//			}
//		}
//		else
//		{
//			if(m_isTouched && m_mouseJoint)
//			{
//				//ForceOnBox(settings);
//			}
//			static int timeStep = 0;
//			if(settings->isRecord)
//			{
//				Recording(settings, timeStep++);
//			}
//			else
//			{
//				timeStep = 0;
//			}
//		}
//
//		if(m_fingerBody)
//		{
//			b2Vec2 invGravityForce = m_world->GetGravity();
//			invGravityForce *= -1.0f * m_fingerBody->GetMass();
//			m_fingerBody->ApplyForceToCenter(invGravityForce);
//		}
//		
//		if(m_fingerBody)
//		{
//			b2Vec2 externalForce;
//			externalForce.SetZero();
//			if(m_mouseJoint)
//				externalForce = m_mouseJoint->GetReactionForce(settings->hz);
//			b2Vec2 invGravityForce = m_world->GetGravity();
//			invGravityForce *= -1.0f * m_fingerBody->GetMass();
//			externalForce += invGravityForce;
//			m_externalForceCollection.push_back(externalForce);
//			m_fingerPositionCollection.push_back(m_fingerPosition);
//		}
//		DrawInfo();
//		Test::Step(settings);
//	}
//
//	void DrawInfo()
//	{
//		{
//			char infoValue[15];
//			char title[50] = "BoxSize: ";
//			sprintf(infoValue, "%.6f", m_boxSize);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[30] = "BoxDensity: ";
//			sprintf(infoValue, "%.6f", m_boxDensity);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[50] = "BoxFriction: ";
//			sprintf(infoValue, "%.6f", m_boxFriction);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[50] = "FingerFriction: ";
//			sprintf(infoValue, "%.6f", m_fingerFriction);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[50] = "GroundFriction: ";
//			sprintf(infoValue, "%.6f", m_groundFriction);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[50] = "MouseJointFrequency: ";
//			sprintf(infoValue, "%.6f", m_mouseJointFrequency);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[15];
//			char title[50] = "MouseJointDampingRatio: ";
//			sprintf(infoValue, "%.6f", m_mouseJointDampingRatio);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//
//		{
//			char infoValue[20];
//			char title[50] = "GroundBodyPosition: ";
//			sprintf(infoValue, "%.6f %.6f", m_groundPosition.x, m_groundPosition.y);
//			m_debugDraw.DrawString(5, m_textLine, strcat(title, infoValue));
//			m_textLine += 15;
//		}
//	}
//
//	string CurrentDateTime() 
//	{
//		time_t now = time(0);
//		struct tm  tstruct;
//		char buf[80];
//		tstruct = *localtime(&now);
//		strftime(buf, sizeof(buf), "%Y-%m-%d-%H-%M-%S", &tstruct);
//		return buf;
//	}
//
//	void Recording(Settings* settings, int timeStep)
//	{
//		if(m_fileName.empty())
//		{
//			m_fileName = CurrentDateTime();
//			settings->fileName = m_fileName;
//		}
//		if(!m_trajectoryOutput)
//		{
//			char path[100] = ".\\trajectory\\";
//			strcat(path, m_fileName.c_str());
//			m_trajectoryOutput = fopen(path, "at+");
//			m_recordInfo.clear();
//		}
//
//		//static int timeStep = 0;
//
//		if(m_mouseJoint == NULL && !m_isTouched)
//		{
//			RecordInfo recordInfo(b2Vec2(m_fingerPosition.x, m_fingerPosition.y), b2Vec2(m_pullPointPosition.x, m_pullPointPosition.y), "1", timeStep);
//			m_recordInfo.push_back(recordInfo);
//			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "1", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);	
//		}
//		else if(m_mouseJoint == NULL && m_isTouched)
//		{
//			RecordInfo recordInfo(b2Vec2(m_fingerPosition.x, m_fingerPosition.y), b2Vec2(m_pullPointPosition.x, m_pullPointPosition.y), "2", timeStep);
//			m_recordInfo.push_back(recordInfo);
//		}
//		else if(m_mouseJoint != NULL && m_isTouched)
//		{
//			RecordInfo recordInfo(b2Vec2(m_fingerPosition.x, m_fingerPosition.y), b2Vec2(m_pullPointPosition.x, m_pullPointPosition.y), "3", timeStep);
//			m_recordInfo.push_back(recordInfo);
//			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "3", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);
//		}
//		else if(m_mouseJoint != NULL && !m_isTouched)
//		{
//			RecordInfo recordInfo(b2Vec2(m_fingerPosition.x, m_fingerPosition.y), b2Vec2(m_pullPointPosition.x, m_pullPointPosition.y), "4", timeStep);
//			m_recordInfo.push_back(recordInfo);
//			fprintf(m_trajectoryOutput, "%s %f %f %f %f\n", "4", m_fingerPosition.x, m_fingerPosition.y, m_pullPointPosition.x, m_pullPointPosition.y);
//		}
//	}
//
//	void StopRecord()
//	{
//		if(m_trajectoryOutput)
//		{
//			fclose(m_trajectoryOutput);
//			m_trajectoryOutput = NULL;
//		}
//		m_fileName = "";
//	}
//
//	void AddNoise(Settings* settings)
//	{
//		if(m_mouseJoint)
//		{
//			m_world->DestroyJoint(m_mouseJoint);
//			m_mouseJoint = NULL;
//		}
//		if(m_fingerBody)
//		{
//			m_world->DestroyBody(m_fingerBody);
//			m_fingerBody = NULL;
//			m_fingerPosition = FINGER_POSITION;
//			DrawFinger();
//		}
//		if(m_replayIterations == -1)
//		{
//			m_replayIterations = settings->replayIterations;
//			m_externalForceCollection.clear();
//			m_fingerPositionCollection.clear();
//		}
//		if(m_noiseFlag & e_boxDensityBit)
//		{
//			b2Vec2 boxPosition = m_boxBody->GetPosition();
//			m_boxDensity += 350.0f;
//			if(m_boxBody)
//			{
//				m_world->DestroyBody(m_boxBody);
//				m_boxBody = NULL;
//			}
//			DrawBox(boxPosition);
//		}
//		if(m_noiseFlag & e_boxSizeBit)
//		{
//			b2Vec2 boxPosition = m_boxBody->GetPosition();
//			m_boxSize += 0.01f;
//			boxPosition.x += 0.01f;
//			boxPosition.y += 0.01f;
//			if(m_boxBody)
//			{
//				m_world->DestroyBody(m_boxBody);
//				m_boxBody = NULL;
//			}
//			DrawBox(boxPosition);
//		}
//		if(m_noiseFlag & e_boxFrictionBit)
//		{
//			b2Vec2 boxPosition = m_boxBody->GetPosition();
//			m_boxFriction += 0.1f;
//			if(m_boxBody)
//			{
//				m_world->DestroyBody(m_boxBody);
//				m_boxBody = NULL;
//			}
//			DrawBox(boxPosition);
//		}
//		if(m_noiseFlag & e_fingerFrictionBit)
//		{
//			m_fingerFriction += 0.05f;
//			if(m_fingerFriction > 1.0f)
//				m_fingerFriction = 1.0f;
//			m_fingerPosition = FINGER_POSITION;
//			DrawFinger();
//		}
//		if(m_noiseFlag & e_groundFrictionBit)
//		{
//			m_groundFriction += 0.05f;
//			if(m_groundFriction > 1.0f)
//				m_groundFriction = 1.0f;
//
//			if(m_groundBody)
//			{
//				m_world->DestroyBody(m_groundBody);
//				m_groundBody = NULL;
//			}
//			DrawGround(m_groundPosition);
//		}
//		if(m_noiseFlag & e_frequencyBit)
//		{
//			m_mouseJointFrequency += 0.5f;
//			if(m_mouseJoint)
//			{
//				m_world->DestroyJoint(m_mouseJoint);
//				m_mouseJoint = NULL;
//			}
//		}
//		if(m_noiseFlag & e_dampingRatioBit)
//		{
//			m_mouseJointDampingRatio += 0.05f;
//			if(m_mouseJoint)
//			{
//				m_world->DestroyJoint(m_mouseJoint);
//				m_mouseJoint = NULL;
//			}
//		}
//		if(m_noiseFlag & e_groundShiftingBit)
//		{
//			m_groundPosition.y += 0.1f;
//
//			if(m_groundBody)
//			{
//				m_world->DestroyBody(m_groundBody);
//				m_groundBody = NULL;
//			}
//			DrawGround(m_groundPosition);
//
//			b2Vec2 boxPosition = m_boxBody->GetPosition();
//			boxPosition.y += 0.1f;
//			if(m_boxBody)
//			{
//				m_world->DestroyBody(m_boxBody);
//				m_boxBody = NULL;
//			}
//			DrawBox(boxPosition);
//		}
//	}
//
//	void StopReplay(Settings* settings)
//	{
//		static int iterNum = 1;
//		char iterStr[4];
//		itoa(iterNum, iterStr, 10);
//
//		if(m_dataFile == NULL)
//		{
//			m_dataFile = fopen(".\\data_file_name", "w");
//		}
//		fprintf(m_dataFile, "%s-%d\n", settings->fileName.c_str(), iterNum);
//
//		uint32 flags = 0;
//		flags += settings->enableForceDataWrite * e_writeForce;
//		flags += settings->enablePositionDataWrite * e_writePosition;
//
//		if(flags & e_writeForce)
//		{	
//			char path[100] = ".\\figure_data\\force\\";
//			strcat(strcat(strcat(path, settings->fileName.c_str()),"-"), iterStr);
//			FILE* forceDataOutput = fopen(path, "w");
//			vector<b2Vec2>::iterator iter;
//			for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++) 
//				fprintf(forceDataOutput, "%f %f\n", (*iter).x, (*iter).y);
//			fclose(forceDataOutput);
//		}
//
//		if(flags & e_writePosition)
//		{
//			char path[100] = ".\\figure_data\\position\\";
//			strcat(strcat(strcat(path, settings->fileName.c_str()),"-"), iterStr);
//			FILE* positionDataOutput = fopen(path, "w");
//			vector<b2Vec2>::iterator iter;
//			for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++) 
//				fprintf(positionDataOutput, "%f %f\n", (*iter).x, (*iter).y);
//			fclose(positionDataOutput);
//		}
//
//		if(m_replayIterations == 0)
//		{
//			settings->isReplay = !settings->isReplay;
//
//			m_boxFriction = BOX_FRICTION;
//			m_groundFriction = GROUND_FRICTION;
//			m_fingerFriction = FINGER_FRICTION;
//			m_boxDensity = BOX_DENSITY;
//			m_boxSize = BOX_SIZE;
//			m_fingerDensity = FINGER_DENSITY;
//			m_fingerSize = FINGER_SIZE;
//			m_mouseJointFrequency = MOUSE_JOINT_FREQUENCY;
//			m_mouseJointDampingRatio = MOUSE_JOINT_DAMPING_RATIO;
//			m_groundPosition = GROUND_POSITION;
//			m_fingerPosition = FINGER_POSITION;
//
//			if(m_boxBody)
//			{
//				m_world -> DestroyBody(m_boxBody);
//				m_boxBody = NULL;
//				DrawBox(b2Vec2(-1.5f + m_boxSize, m_groundPosition.y + m_boxSize));
//			}
//
//			if(m_groundBody)
//			{
//				m_world -> DestroyBody(m_groundBody);
//				m_groundBody = NULL;
//				DrawGround(m_groundPosition);
//			}
//
//			if(m_fingerBody)
//			{
//				m_world -> DestroyBody(m_fingerBody);
//				m_fingerBody = NULL;
//				DrawFinger();
//			}
//
//			m_replayIterations = -1;
//			iterNum = 1;
//			fclose(m_dataFile);
//			m_dataFile = NULL;
//		}
//
//		iterNum++;
//
//		if(m_trajectoryInput)
//		{		
//			fclose(m_trajectoryInput);
//			m_trajectoryInput = NULL;
//		}
//
//		if(m_mouseJoint)
//		{
//			m_world->DestroyJoint(m_mouseJoint);
//			m_mouseJoint = NULL;
//		}
//	}
//
//	void DrawForceX()
//	{
//		m_debugDraw.DrawString(45, 10, "Force X (N) (SCALE 1/10000)");
//		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
//
//		int i = 0;
//		vector<b2Vec2>::iterator iter;
//		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
//		{ 
//			if(iter + 1 != m_externalForceCollection.end())
//			{
//				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
//			}
//		}
//	}
//
//	void DrawForceY()
//	{
//		m_debugDraw.DrawString(45, 10, "Force Y (N) (SCALE 1/10000)");
//		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
//
//		int i = 0;
//		vector<b2Vec2>::iterator iter;
//		for(iter = m_externalForceCollection.begin(); iter != m_externalForceCollection.end(); iter++, i++) 
//		{ 
//			if(iter + 1 != m_externalForceCollection.end())
//			{
//				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * FORCE_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * FORCE_SCALE), b2Color(0.1f, 0.1f, 1.0f));
//			}
//		}
//	}
//
//	void DrawPositionX()
//	{
//		m_debugDraw.DrawString(45, 10, "Position X (M) (SCALE 1/2)");
//		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
//
//		int i = 0;
//		vector<b2Vec2>::iterator iter;
//		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
//		{ 
//			if(iter + 1 != m_fingerPositionCollection.end())
//			{
//				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).x * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).x * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
//			}
//		}
//	}
//
//	void DrawPositionY()
//	{
//		m_debugDraw.DrawString(45, 10, "Position Y (M) (SCALE 1/2)");
//		m_debugDraw.DrawString(1420, 190, "TIME (S) (STEP 1/60)");
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, 0.0f), b2Vec2(1.0f, 0.0f), b2Color(0.9f, 0.9f, 0.9f));
//		m_debugDraw.DrawSegment(b2Vec2(-0.95f, -1.0f), b2Vec2(-0.95f, 1.0f), b2Color(0.9f, 0.9f, 0.9f));
//
//		int i = 0;
//		vector<b2Vec2>::iterator iter;
//		for(iter = m_fingerPositionCollection.begin(); iter != m_fingerPositionCollection.end(); iter++, i++) 
//		{ 
//			if(iter + 1 != m_fingerPositionCollection.end())
//			{
//				m_debugDraw.DrawSegment(b2Vec2(-0.95f + SPACE * i, (*iter).y * POSITION_SCALE), b2Vec2(-0.95f + SPACE * (i + 1), (*(iter + 1)).y * POSITION_SCALE), b2Color(0.1f, 0.1f, 1.0f));
//			}
//		}
//	}
//
//	b2Body* m_boxBody;
//	b2Body* m_fingerBody;
//	b2Body* m_groundBody;
//	b2Fixture* m_fingerFixture;
//	bool m_isTouched;
//	b2Vec2 m_fingerPosition;
//	b2Vec2 m_pullPointPosition;
//	FILE* m_trajectoryInput;
//	FILE* m_trajectoryOutput;
//	FILE* m_dataFile;
//	string m_fileName;
//	string m_flag;
//	uint32 m_noiseFlag;
//	int32 m_replayIterations;
//	b2Vec2 m_linearVelocity;
//	b2Vec2 m_linearVelocityOld;
//	std::vector<b2Vec2> m_externalForceCollection;
//	std::vector<b2Vec2> m_fingerPositionCollection;
//	float32 m_boxFriction;
//	float32 m_groundFriction;
//	float32 m_fingerFriction;
//	float32 m_boxDensity;
//	float32 m_boxSize;
//	float32 m_fingerSize;
//	float32 m_fingerDensity;
//	float32 m_mouseJointFrequency;
//	float32 m_mouseJointDampingRatio;
//	b2Vec2 m_groundPosition;
//	vector<RecordInfo> m_recordInfo;
//	bool m_shiftingAdaptionStart;
//	bool m_shiftingAdaptionEnd;
//	b2Vec2 m_recordedFingerPosition;
//	float32 m_adaptiveDiff;
//};
//
//#endif
//
